package com.google.code.task.example;

import static com.google.code.task.Style.endTask;
import static com.google.code.task.Style.failover;
import static com.google.code.task.Style.retryCount;
import static com.google.code.task.Style.retryFailOver;
import static com.google.code.task.Style.startTask;
import static com.google.code.task.Style.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.code.task.example.resources.LoggingFailoverTask;
import com.google.code.task.example.resources.ToBeFailedTask;

public class RetryFailoverDecoratorExample {
  static final Log LOG = LogFactory.getLog(RetryFailoverDecoratorExample.class);

  public static void main(String[] args) throws Exception {
    startTask();
    new ToBeFailedTask()
      .failover(new LoggingFailoverTask())
        .retryCount(3)
      .execute();
    endTask();
    
    startTask();
    retryFailOver(
        task(new ToBeFailedTask()),
        failover(new LoggingFailoverTask()),
        retryCount(3)
    ).execute();
    endTask();
  }
}
